package com.zx._12_算法.字节跳动面试题;

import com.zx._12_算法.LinkNode;

public class 两个链表求和 {

    public static void main(String[] args) {
        LinkNode node1 = LinkNode.getNodes(1, 2, 3, 4);
        LinkNode node2 = LinkNode.getNodes(2, 3, 4);

        int sum = 0;
        while (true) {

            if (node1 != null) {
                sum += node1.data;
                node1 = node1.next;
            }
            if (node2 != null) {
                sum += node2.data;
                node2 = node2.next;
            }

            if (node1 == null && node2 == null) {
                break;
            }
        }
        System.out.println(sum);
    }
}
